﻿/*
Copyright (c) 2010 Vratislav Cermak (vratacermak@gmail.com)
 
This file is part of TeachMe Project. See http://code.google.com/p/teach-me for more information.
 
TeachMe is an open source project. Using of TeachMe is free of charge.
It is distributed under GNU General Public License version 3 (GPLv3).
GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
 
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

using System;
using System.Collections.Generic;
using TeachMe.Application.Properties;

namespace TeachMe.Application
{
    public class Languages
    {
        public class Item
        {
            public string Code { get; set; }
            public string Localized { get; set; }

            public override string ToString()
            {
                return Localized;
            }
        }

        public static readonly List<Item> Items;

        static Languages()
        {
            Items = new List<Item>
                        {
                            new Item {Code = "cz", Localized = Resources.LanguageCzech},
                            new Item {Code = "fr", Localized = Resources.LanguageFrench},
                            new Item {Code = "en", Localized = Resources.LanguageEnglish},
                            new Item {Code = "it", Localized = Resources.LanguageItalian},
                            new Item {Code = "es", Localized = Resources.LanguageSpanish},
                            new Item {Code = "de", Localized = Resources.LanguageGerman},
                            new Item {Code = "ru", Localized = Resources.LanguageRussian},
                            new Item {Code = "fi", Localized = Resources.LanguageFinnish},
                            new Item {Code = "ar", Localized = Resources.LanguageArabic}
                        };
        }

        public static Item GetByCode(string code)
        {
            foreach (Item item in Items)
            {
                if (String.Compare(item.Code, code, true) == 0)
                {
                    return item;
                }
            }

            return null;
        }
    }
}
